package com.yangxin.lesson.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/** @Author yangxinxin
 * @Description //TODO
 * @Date 18:53 2020/2/12
 * @Param
 * @return
 **/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Value("${swagger2.enable}")
    private boolean enable;
    @Bean
    public Docket createDocker(){
        //基本信息
        Docket build = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()//暴露那些接口
                .apis(RequestHandlerSelectors.basePackage("com.yangxin.lesson.web.controller"))//指定接口包名
                .paths(PathSelectors.any())
                .build()
                .enable(enable);
        return build;

    }
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("Spring boot 2.0视频教程！")
                .description("Spring boot 2.0零教程到高级教程的实战视频！")
                .version("1.0.0")
                .build();


    }


}
